package IC.SemanticChecks;

import IC.AST.*;

/**
 *	a visitor class that is used to check if a break & continue commands are used only at loops.
 */
public class BreakContCheckingVisitor implements Visitor {
	
	//C'tor
	public BreakContCheckingVisitor(){
		
	}
		
	public Object visit(Program program) {
		for (ICClass c : program.getClasses()) 
			c.accept(this);
		return null;
	}

	public Object visit(ICClass icClass) {
		for (Method m : icClass.getMethods())
			m.accept(this);
		return null;
	}

	public Object visit(VirtualMethod method) {
		for (Statement s : method.getStatements()) 
			s.accept(this);
		return null;
	}

	public Object visit(StaticMethod method) {
		for (Statement s : method.getStatements())
			s.accept(this);
		return null;
	}
	
	public Object visit(Break breakStatement) {
		SemanticError.handle(SemanticErrorType.INVALID_BREAK, breakStatement.getLine());
		return null;
	}

	public Object visit(Continue continueStatement) {
		SemanticError.handle(SemanticErrorType.INVALID_CONTINUE, continueStatement.getLine());
		return null;
	}

	public Object visit(StatementsBlock statementsBlock) {
		for (Statement s : statementsBlock.getStatements())
			s.accept(this);
		return null;
	}
	
	public Object visit(If ifStatement) {
		ifStatement.getOperation().accept(this);
		if(ifStatement.hasElse())
			ifStatement.getElseOperation().accept(this);
		return null;
	}
	
	public Object visit(Field field) {
		return null;
	}
	
	public Object visit(LibraryMethod method) {
		return null;
	}

	public Object visit(Formal formal) {
		return null;
	}

	public Object visit(PrimitiveType type) {
		return null;
	}

	public Object visit(UserType type) {
		return null;
	}

	public Object visit(Assignment assignment) {
		return null;
	}

	public Object visit(CallStatement callStatement) {
		return null;
	}

	public Object visit(Return returnStatement) {
		return null;
	}

	public Object visit(While whileStatement) {
		return null;
	}

	public Object visit(LocalVariable localVariable) {
		return null;
	}

	public Object visit(VariableLocation location) {
		return null;
	}

	public Object visit(ArrayLocation location) {
		return null;
	}

	public Object visit(StaticCall call) {
		return null;
	}

	public Object visit(VirtualCall call) {
		return null;
	}

	public Object visit(This thisExpression) {
		return null;
	}

	public Object visit(NewClass newClass) {
		return null;
	}

	public Object visit(NewArray newArray) {
		return null;
	}

	public Object visit(Length length) {
		return null;
	}

	public Object visit(MathBinaryOp binaryOp) {
		return null;
	}

	public Object visit(LogicalBinaryOp binaryOp) {
		return null;
	}

	public Object visit(MathUnaryOp unaryOp) {
		return null;
	}

	public Object visit(LogicalUnaryOp unaryOp) {
		return null;
	}

	public Object visit(Literal literal) {
		return null;
	}

	public Object visit(ExpressionBlock expressionBlock) {
		return null;
	}
	
}
